package com.jjr.cosmetology.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class Swagger2Config {
    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(UIInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.jjr.cosmetology.controller"))
                .paths(PathSelectors.any())
                .build();
    }
    //apiInfo指的是接口文档信息
    private ApiInfo UIInfo(){
        return new ApiInfoBuilder()
                .title("美容预约平台api") //标题
                .description("美容预约平台的接口文档")  //对这个接口文档的描述信息
                .contact(new Contact("xiyang","","710379711@qq.com"))  //作者的联系方式
                .termsOfServiceUrl("http://localhost:8080")  //项目主页面的访问地址
                .version("1.0") //版本号
                .build();


    }





}
